package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysContractRefundReport;
import com.ruoyi.system.service.ISysContractRefundReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 挽单报告Controller
 *
 * @author ruoyi
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/system/refund/report")
public class SysContractRefundReportController extends BaseController
{
    @Autowired
    private ISysContractRefundReportService sysContractRefundReportService;

    /**
     * 查询挽单报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysContractRefundReport sysContractRefundReport)
    {
        startPage();
        List<SysContractRefundReport> list = sysContractRefundReportService.selectSysContractRefundReportList(sysContractRefundReport);
        return getDataTable(list);
    }

    /**
     * 导出挽单报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:report:export')")
    @Log(title = "挽单报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysContractRefundReport sysContractRefundReport)
    {
        List<SysContractRefundReport> list = sysContractRefundReportService.selectSysContractRefundReportList(sysContractRefundReport);
        ExcelUtil<SysContractRefundReport> util = new ExcelUtil<SysContractRefundReport>(SysContractRefundReport.class);
        util.exportExcel(response, list, "挽单报告数据");
    }

    /**
     * 获取挽单报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysContractRefundReportService.selectSysContractRefundReportById(id));
    }

    /**
     * 新增挽单报告
     */
    //@PreAuthorize("@ss.hasPermi('system:report:add')")
    @Log(title = "挽单报告", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysContractRefundReport sysContractRefundReport)
    {
        return toAjax(sysContractRefundReportService.insertSysContractRefundReport(sysContractRefundReport));
    }

    /**
     * 修改挽单报告
     */
    @PreAuthorize("@ss.hasPermi('system:report:edit')")
    @Log(title = "挽单报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysContractRefundReport sysContractRefundReport)
    {
        return toAjax(sysContractRefundReportService.updateSysContractRefundReport(sysContractRefundReport));
    }

    /**
     * 删除挽单报告
     */
    @PreAuthorize("@ss.hasPermi('system:report:remove')")
    @Log(title = "挽单报告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysContractRefundReportService.deleteSysContractRefundReportByIds(ids));
    }
}